const icons=[]
loadVue('/http/assert.js',(module)=>{
    module.getIcons().then(res=>{
        icons.push(...res.data)
        const svgObj = document.createElement("svg");
        svgObj.setAttribute("xmlns","http://www.w3.org/2000/svg")
        svgObj.setAttribute("xmlns:link","http://www.w3.org/1999/xlink")
        svgObj.setAttribute("style","position:absolute;width:0;height:0")
        //document.body.appendChild(svgObj)
        document.body.insertBefore(svgObj,document.getElementById('app'));
        Promise.all(icons.map(icon=>{
            return fetch(`./public/images/icons/${icon}.svg`)
                .then(response => response.text())
                .then(svg => {
                    const parser = new DOMParser();
                    const svgDoc = parser.parseFromString(svg, 'image/svg+xml')
                    const svgElement = svgDoc.documentElement; // 获取解析后的SVG元素
                    const symbol = document.createElementNS("http://www.w3.org/2000/svg","symbol")
                    const viewBox = svgElement.getAttribute("viewBox");
                    symbol.setAttribute("viewBox",viewBox?viewBox:"0 0 128 128");
                    symbol.setAttribute("class","icon")
                    symbol.id = 'icon-'+icon;
                    symbol.innerHTML = svgElement.innerHTML
                    svgObj.appendChild(symbol)

                });
        })).then(()=>{
            // console.log("svg load over")
        })

    })
})

